package com.gt.aep.base.service.systemManage;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gt.aep.base.dao.systemManage.SysIdentityRoleUserDao;
import com.gt.aep.base.entity.systemManage.SysIdentityRole;
import com.gt.aep.base.entity.systemManage.SysIdentityRoleUser;
import com.gt.aep.base.entity.systemManage.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysIdentityRoleUserService {

    @Autowired
    SysIdentityRoleUserDao sysIdentityRoleUserDao;

    /**
     * 新增身份角色-用户关系
     * @param sysIdentityRole
     * @return
     */
    public int insert(SysIdentityRoleUser sysIdentityRole){
        return sysIdentityRoleUserDao.insert(sysIdentityRole);
    }

    /**
     * 修改身份角色-用户关系
     * @param sysIdentityRole
     * @return
     */
    public int update(SysIdentityRoleUser sysIdentityRole){
        return sysIdentityRoleUserDao.update(sysIdentityRole);
    }

    /**
     * 批量删除身份角色-用户关系
     * @param ids
     * @return
     */
    public int delete(String[] ids){
        return sysIdentityRoleUserDao.delete(ids);
    }

    /**
     * 根据用户id查询身份角色列表
     * @param uid 用户id
     * @return
     */
    public List<SysIdentityRole> getListByUid(String uid){
        return sysIdentityRoleUserDao.getListByUid(uid);
    }

    /**
     * 根据用户id查询身份角色个数
     * @param uid 用户id
     * @return
     */
    public int getCountByUid(String uid){
        return sysIdentityRoleUserDao.getCountByUid(uid);
    }

    /**
     * 根据身份角色id获取用户列表
     * @param identityRoleId 身份角色id
     * @return
     */
    public List<SysUser> getListByIdentityRoleId(String identityRoleId){
        return sysIdentityRoleUserDao.getListByIdentityRoleId(identityRoleId);
    }


    /**
     * 根据身份角色id获取符合的用户个数
     * @param identityRoleId
     * @return
     */
    public int getCountByIdentityRoleId(String identityRoleId){
        return sysIdentityRoleUserDao.getCountByIdentityRoleId(identityRoleId);
    }

    /**
     * 清除与userId相关的记录
     * @param userId
     * @return
     */
    public int deleteByUid(String userId) {
        return sysIdentityRoleUserDao.deleteByUid(userId);
    }
}
